#include <iostream>
#include <string>
#include <unordered_map>
#include <gtest/gtest.h>
using namespace std;

unordered_map<string, string> hash;
class GlobalTest : public testing::Environment
{
public:

    virtual void SetUp() override
    {
        cout << "全局测试初始化，插入数据" <<endl;
        ::hash["apple"] = "苹果";
        ::hash["pen"] = "笔";
    }

    virtual void TearDown() override
    {
        ::hash.clear();
        cout << "全局测试清除" <<endl;
    }

private:
};

TEST(hash_test, test_size)
{
    ASSERT_EQ(::hash.size(), 2);
    ::hash.erase("apple");
}

TEST(hash_test, test_erase)
{
    ASSERT_EQ(::hash.size(), 1);
}


int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new GlobalTest());
    cout << "RUN_ALL_TESTS: " << RUN_ALL_TESTS() << endl;

    return 0;
}